{% extends "layout/home_base.html" %}
{% block home_content %}
<div class="section">
  <div class="section__header">
    <h1 class="section__title">{{ _('My Files') }}</h1>
    <div class="section__tools">
    {% if handler.has_priv(vj4.model.builtin.PRIV_CREATE_FILE) %}
      <a class="primary rounded button" href="{{ reverse_url('fs_upload') }}" target="_blank"><span class="icon icon-add"></span> {{ _('Upload File') }}</a>
    {% endif %}
      <a class="tool-button" href="{{ reverse_url('wiki_help') }}#file"><span class="icon icon-help"></span> {{ _('What\'s file?') }}</a>
    </div>
  </div>
  <div class="section__body no-padding">
    <table class="data-table">
      <colgroup>
        <col class="col--desc">
        <col class="col--length">
        <col class="col--hash">
        <col class="col--action">
      </colgroup>
      <thead>
        <tr>
          <th class="col--desc">{{ _('Description') }}</th>
          <th class="col--length">{{ _('Size') }}</th>
          <th class="col--hash">{{ _('Hash') }}</th>
          <th class="col--action">{{ _('Action') }}</th>
        </tr>
      </thead>
      <tbody>
      {% for ufdoc in ufdocs %}
      {% with fdoc = fdict.get(ufdoc['file_id'], {}) %}
        <tr>
          <td class="col--desc">{{ ufdoc['content'] }}</td>
          <td class="col--length">{{ fdoc['length']|format_size if fdoc['length'] else '?' }}</td>
          <td class="col--hash">{{ fdoc['md5']|default('?') }}</td>
          <td class="col--action"><a class="typo-a" href="{{ handler.file_url(fdoc) if 'metadata' in fdoc else '#' }}">{{ _('Download') }}</a> · <a class="typo-a" href="#">{{ _('Code') }}</a></td>
        </tr>
      {% endwith %}
      {% endfor %}
      </tbody>
    </table>
  </div>
</div>
{% endblock %}
